package com.zjeav.lingjiao.base.view;

/**
 * Created by kekezhou on 2018-10-31.
 */

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zjeav.lingjiao.R;
import com.zjeav.lingjiao.base.config.BaseConfig;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 选择支付方式Dialog
 * Created by Hh on 2017/3/6.
 */

public class PayWayDialog extends Dialog implements View.OnClickListener{
    TextView dialogBalance;

    LinearLayout dialogMyWallet;
    RelativeLayout dialog_zhifubao,dialog_wechat;

    ImageView recharge_wallet_cb,recharge_zhifubao_cb,recharge_wechat_cb;

    TextView rechargeNum;

    TextView dialogConfirmPay;

    /** 判断是充值&支付 **/
    private boolean isRecharge;

    private View.OnClickListener onClickListener;

    /** 区别三种支付方式 0:我的钱包 1:支付宝 2:微信支付 **/
    public static int payWay = BaseConfig.MY_WALLET;

    private Context context;

    /**
     *  如果ifRecharge 传入true 则是充值,就隐藏掉我的钱包, 否则则显示
     * @param context
     * @param themeResId
     * @param isRecharge
     * @param onClickListener
     */
    public PayWayDialog(Context context, int themeResId, boolean isRecharge, View.OnClickListener onClickListener) {
        super(context, themeResId);
        this.context = context;
        this.isRecharge = isRecharge;
        this.onClickListener = onClickListener;
    }

    private void initView(){
        dialog_zhifubao=findViewById(R.id.dialog_zhifubao);
        dialog_wechat=findViewById(R.id.dialog_wechat);
        dialog_zhifubao.setOnClickListener(this);
        dialog_wechat.setOnClickListener(this);
        recharge_zhifubao_cb=findViewById(R.id.recharge_zhifubao_cb);
        recharge_wechat_cb=findViewById(R.id.recharge_wechat_cb);
        dialogConfirmPay=findViewById(R.id.dialog_confirm_pay);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_pay);
        initView();
        if (isRecharge) {
            dialogMyWallet.setVisibility(View.GONE);
//            checks.get(1).setVisibility(View.VISIBLE);
            payWay = BaseConfig.Alipay;
        }
        Window dialogWindow = getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = AbsListView.LayoutParams.MATCH_PARENT;
        lp.y = 0;//设置Dialog距离底部的距离
        dialogWindow.setAttributes(lp);
        dialogConfirmPay.setOnClickListener(onClickListener);
    }




    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.recharge_dialog_close:
                dismiss();
                break;
            case R.id.dialog_zhifubao:

                break;
            case R.id.dialog_wechat:

                break;
        }
    }


}